<h2>Receivables</h2>
<h2><?php echo $owner->getListName()?></h2>
<h3>as of <?php echo date('m/d/Y',strtotime($asof_date))?></h3>
<?php $total_notdue = 0?>
<?php $total_due30 = 0?>
<?php $total_due60 = 0?>
<?php $total_due90 = 0?>
<?php $total_due120 = 0?>
<?php $total_overdue = 0?>
<?php $total = 0?>
<table class="datagrid">
  <thead class="datagrid">
    <tr>
      <th>Customer</th>
      <th>Not Due</th>
      <th>Overdue 30</th>
      <th>Overdue 60</th>
      <th>Overdue 90</th>
      <th>Overdue 120 up</th>
      <th>Total Overdue</th>
      <th>Total Receivable</th>
    </tr>
  </thead>
  <tbody class="datagrid" style="height:auto;">
    <?php foreach($receivables as $receivable):?>
      <tr>
        <td><?php echo $receivable['list_name']?></td>
        <td style="text-align:right;"><?php echo number_format($receivable['total_notdue'],2)?></td>
        <td style="text-align:right;"><?php echo number_format($receivable['total_due30'],2)?></td>
        <td style="text-align:right;"><?php echo number_format($receivable['total_due60'],2)?></td>
        <td style="text-align:right;"><?php echo number_format($receivable['total_due90'],2)?></td>
        <td style="text-align:right;"><?php echo number_format($receivable['total_due120'],2)?></td>
	<?php $overdue = $receivable['total_notdue']+$receivable['total_due30']+$receivable['total_due60']+$receivable['total_due90']+$receivable['total_due120'];?>
        <td style="text-align:right;"><?php echo number_format($overdue,2)?></td>
        <td style="text-align:right;"><?php echo number_format($receivable['total'],2)?></td>
      </tr>
      <?php $total_notdue += $receivable['total_notdue']?>
      <?php $total_due30 += $receivable['total_due30']?>
      <?php $total_due60 += $receivable['total_due60']?>
      <?php $total_due90 += $receivable['total_due90']?>
      <?php $total_due120 += $receivable['total_due120']?>
      <?php $total_overdue += $overdue?>
      <?php $total += $receivable['total']?>
    <?php endforeach;?>
  </tbody>
  <tfoot class="datagrid">
      <tr>
        <td>TOTAL RECEIVABLES</td>
        <td style="text-align:right;"><?php echo number_format($total_notdue,2)?></td>
        <td style="text-align:right;"><?php echo number_format($total_due30,2)?></td>
        <td style="text-align:right;"><?php echo number_format($total_due60,2)?></td>
        <td style="text-align:right;"><?php echo number_format($total_due90,2)?></td>
        <td style="text-align:right;"><?php echo number_format($total_due120,2)?></td>
        <td style="text-align:right;"><?php echo number_format($total_overdue,2)?></td>
        <td style="text-align:right;"><?php echo number_format($total,2)?></td>
      </tr>
  </tfoot>
</table>
